package com.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.model.ScreenResume;
import com.model.ScreenResume;
import com.service.ScreenResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 简历评估表 前端控制器
 * </p>
 *
 * @author Damon
 * @since 2021-04-28
 */
@RequestMapping("/screen_resume")
@RestController
public class ScreenResumeController{
    //列表数据 支持分页和条件查询
    @Autowired
    private ScreenResumeService screenResumeService;
    //例表数据
    @RequestMapping("/list")
    public Page<ScreenResume> list(Long pageNum, Long size){
        //分页对象
        Page<ScreenResume> page = new Page<>(pageNum, size);
        page = screenResumeService.listPage(page);
        return page;
    }
    //列表数据JSON
    @RequestMapping("/listAll")
    public Page<ScreenResume> listAll(String realNameS, Long pageNum, Long size) {
        //分页对象
        Page<ScreenResume> page = new Page<ScreenResume>(pageNum, size);
        page = screenResumeService.getListAll(page,new ScreenResume(0,realNameS,null));
        return page;
    }
    /*public List<ScreenResume> listAll(){
        List<ScreenResume> list = screenResumeService.list();
        return list;
    }*/

    /*//新增和修改
    @RequestMapping("/edit")
    public boolean edit(@RequestBody ScreenResume ScreenResume){
        boolean rmw = false;
        ScreenResume.setUpdateDate(LocalDateTime.now());
        ScreenResume.setCreateDate(LocalDateTime.now());
//        ScreenResume.setStartDate();
        if("0".equals(ScreenResume.getModify())){
            //新增
            rmw =ScreenResumeService.save(ScreenResume);
        }else{
            //修改
            rmw = ScreenResumeService.updateById(ScreenResume);
        }
        return rmw;
    }*/

    //新增和修改2
    @RequestMapping("/edit")
    public boolean edit(@RequestBody ScreenResume screenResume){
        boolean res = false;
        if("0".equals(screenResume.getModify())){
            //新增
            res =screenResumeService.save(screenResume);
        }else{
            //修改
            res = screenResumeService.updateById(screenResume);
        }
        return res;
    }

    @RequestMapping("/getByScreenKey")
    public ScreenResume getByScreenId(int screenKey){
        return screenResumeService.getById(screenKey);
    }

    @RequestMapping("/del")
    public boolean del(ScreenResume ScreenResume){
        return screenResumeService.removeById(ScreenResume.getResumeKey());
    }
}

